home *** CD-ROM | disk | FTP | other *** search
-
- /*© Copyright 1988-1992 UserLand Software, Inc. All Rights Reserved.*/
-
- #include "iacinternal.h"
-
- #if __option (a4_globals)
-
- #include <SetupA4.h>
-
- #endif
-
-
- /*
- 8/24/92 DW: This file includes routines that are likely to be used by code
- that sends Apple Events.
- */
-
- /*
- 6/6/93 JWB: Change #ifdef coderesource instances to #if __option (a4_globals)
- to make this automatic.
- Change a4IACwaitroutine () to forward the value returned by
- IACwaitroutine ()
- */
-
-
- Boolean IACnewverb (OSType receiver, OSType vclass, OSType vtoken, AppleEvent *event) {
-
- /*
- create a new AppleEvent record addressed to the recipient, of the indicated class,
- with the indicated token identifier. return true if it worked, false otherwise.
- */
-
- AEAddressDesc adr;
- OSErr errcode;
-
- AECreateDesc (typeApplSignature, (Ptr) &receiver, sizeof (receiver), &adr);
-
- errcode = AECreateAppleEvent (
-
- vclass, vtoken, &adr, kAutoGenerateReturnID, kAnyTransactionID, event);
-
- AEDisposeDesc (&adr);
-
- IACglobals.errorcode = errcode;
-
- return (errcode == noErr);
- } /*IACnewverb*/
-
-
- #if __option (a4_globals)
-
- static pascal short a4IACwaitroutine (EventRecord *ev, long *sleep, RgnHandle *mousergn) {
-
- short result;
-
- SetUpA4 ();
-
- result = IACwaitroutine (ev, sleep, mousergn);
-
- RestoreA4 ();
-
- return (result);
- } /*a4IACwaitroutine*/
-
- #endif
-
-
- Boolean IACsendverb (AppleEvent *event, AppleEvent *reply) {
-
- /*
- caller must dispose of the reply.
- */
-
- register OSErr ec;
- long mode;
-
- mode = kAEWaitReply + kAECanInteract + kAECanSwitchLayer;
-
- #if __option (a4_globals)
-
- RememberA4 ();
-
- ec = AESend (
-
- event, reply, mode, kAENormalPriority, kNoTimeOut,
-
- (ProcPtr) a4IACwaitroutine, nil);
-
- #else
-
- ec = AESend (
-
- event, reply, mode, kAENormalPriority, kNoTimeOut,
-
- (ProcPtr) IACwaitroutine, nil);
-
- #endif
-
- AEDisposeDesc (event);
-
- IACglobals.errorcode = ec;
-
- return (ec == noErr);
- } /*IACsendverb*/
-
-
- Boolean IACsendverbnoreply (AppleEvent *event, AppleEvent *reply) {
-
- OSErr ec;
- long mode;
-
- mode = kAENoReply + kAENeverInteract;
-
- ec = AESend (event, reply, mode, kAEHighPriority, kNoTimeOut, nil, nil);
-
- AEDisposeDesc (event);
-
- IACglobals.errorcode = ec;
-
- return (ec == noErr);
- } /*IACsendverbnoreply*/
-
-
- Boolean IACiserrorreply (Str255 errorstring) {
-
- /*
- return true if the reply is an error -- if so it has an 'errn' value
- and an 'errs' value. if we return false, the reply is not an error.
- */
-
- OSErr ec;
- AEDesc desc;
-
- ec = AEGetParamDesc (IACglobals.reply, (AEKeyword) 'errn', 'shor', &desc);
-
- if (ec != noErr) /*the reply isn't an error*/
- return (false);
-
- AEDisposeDesc (&desc);
-
- ec = AEGetParamDesc (IACglobals.reply, (AEKeyword) 'errs', 'TEXT', &desc);
-
- if (ec != noErr)
- IACcopystring ("\pUnknown error.", errorstring);
- else {
- long lenstring = GetHandleSize (desc.dataHandle);
-
- if (lenstring > 255)
- lenstring = 255;
-
- errorstring [0] = (char) lenstring;
-
- BlockMove (*desc.dataHandle, &errorstring [1], lenstring);
- }
-
- AEDisposeDesc (&desc);
-
- return (true); /*there was an error returned*/
- } /*IACiserrorreply*/
-
-
- Boolean IACdisposeverb (AppleEvent *event) {
-
- IACglobals.errorcode = AEDisposeDesc (event);
-
- return (IACglobals.errorcode == noErr);
- } /*IACdisposeverb*/
-
-
-
-